home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Overview / CPlusTESample / README < prev    next >
Encoding:
Text File  |  1994-11-18  |  4.9 KB  |  122 lines  |  [TEXT/MPS ]

  1. Macintosh
  2. Sample Code Notes
  3. _______________________________________________________________________________
  4.                                                 Developer Technical Support
  5.  
  6. #14:    CPlusTESample
  7.  
  8. Written by:    Andrew Shebanow
  9.  
  10. Versions:            2.00                    May 1990
  11.                     2.01                    June 1992
  12.  
  13. Components:            AppLib.h                May 1, 1990
  14.                     AppLib.r                May 1, 1990
  15.                     Application.cp            May 1, 1990
  16.                     Application.h            May 1, 1990
  17.                     Document.cp                May 1, 1990
  18.                     Document.h                May 1, 1990
  19.                     Exceptions.cp            May 1, 1990
  20.                     Exceptions.h            May 1, 1990
  21.                     List.cp                    May 1, 1990
  22.                     List.h                    May 1, 1990
  23.                     TECommon.h                May 1, 1990
  24.                     TEDocument.cp            May 1, 1990
  25.                     TEDocument.h            May 1, 1990
  26.                     TESample.cp                May 1, 1990
  27.                     TESample.h                May 1, 1990
  28.                     TESample.make            May 1, 1990
  29.                     TESample.r                May 1, 1990
  30.                     TESampleGlue.a            May 1, 1990
  31.  
  32. From MacApp 2.0:    UMAFailure.a            May 1, 1990
  33.                     UMAFailure.h            May 1, 1990
  34.                     UMAFailure.inc1.p        May 1, 1990
  35.                     UMAFailure.p            May 1, 1990
  36. _______________________________________________________________________________
  37.  
  38. This program requires C, C++, and Asm from MPW 3.1 or greater to build.  It
  39. also uses the Failure handling routines, provided here, from MacApp 2.0.
  40.  
  41. _______________________________________________________________________________
  42.  
  43. This version of TESample has been substantially reworked in C++ to show how a
  44. "typical" object-oriented program could be written.  To this end, what was
  45. once a single source code file has been restructured into a set of classes
  46. which demonstrate the advantages of object-oriented programming.
  47.  
  48. There are four main classes in this program.  Each of these classes has a
  49. definition (.h) file and an implementation (.cp) file.
  50.  
  51. The TApplication class does all of the basic event handling and
  52. initialization necessary for Macintosh toolbox applications.  It maintains a
  53. list of TDocument objects and passes events to the correct TDocument class
  54. when appropriate.
  55.  
  56. The TDocument class does all of the basic document handling work.  TDocument
  57. objects are objects that are associated with a window.  Methods are provided
  58. to deal with update, activate, mouse-click, key down, and other events.  Some
  59. additional classes which implement a linked list of TDocument objects are
  60. provided.
  61.  
  62. The TApplication and TDocument classes together define a basic framework for
  63. Macintosh applications, without having any specific knowledge about the type
  64. of data being displayed by the application's documents.  They are a (very)
  65. crude implementation of the MacApp application model, without the
  66. sophisticated view hierarchy.
  67.  
  68. The TESample class is a subclass of TApplication.  It overrides several
  69. TApplication methods, including those for handling menu commands and cursor
  70. adjustment, and it does some necessary initialization.  Note that we only
  71. need to override a few basic routines--the rest of the work is done in a
  72. generic way by TApplication (isn't OOP great?).
  73.  
  74. The TEDocument class is a subclass of TDocument.  This class contains most
  75. of the special-purpose code for text editing.  In addition to overriding
  76. most of the TDocument methods, it defines a number of additional methods
  77. which are used by the TESample class to get information on the document
  78. state.
  79.  
  80. The UMAFailure files are a hacked up version of MacApp 2.0's UFailure unit.
  81. The Exceptions files are a set of C++ macros that make recovering from errors
  82. easier.
  83.  
  84. Segmentation Strategy
  85. _____________________
  86.  
  87. This program has only one segment, since it isn't really big enough to make
  88. multiple segments worthwhile.  We do unload the data initialization segment
  89. at start time, which frees up some memory.
  90.  
  91. _SetPort Strategy
  92. _________________
  93.  
  94. Toolbox routines do not change the current port.  In spite of this, in this
  95. program we use a strategy of calling _SetPort whenever we want to draw or
  96. make calls which depend upon the current port.  This makes us less vulnerable
  97. to bugs in other software which might alter the current port (such as the
  98. bug (feature?) in many desk accessories which change the port on
  99. _OpenDeskAcc).  Hopefully, this also makes the routines from this program
  100. more self-contained, since they don't depend on the current port setting.
  101.  
  102. Clipboard Strategy
  103. __________________
  104.  
  105. This program does not maintain a private scrap.  Whenever a Cut, Copy, or
  106. Paste occurs, we import or export from the public scrap to TextEdit's scrap
  107. immediately, using the TEToScrap and TEFromScrap routines.  If we did use a
  108. private scrap, the import or export would be in the activate or deactivate
  109. event and suspend or resume event routines, respectively.
  110.  
  111. Version 2.00 Changes
  112. ___________________
  113.  
  114. Version 2.0 adds the ability to open and save documents.  It also allows
  115. the user to open multiple documents.  For error checking, it uses the
  116. Failure unit now instead of the previous if-then-else method.
  117.  
  118. Version 2.01 Changes
  119. ___________________
  120.  
  121. Version 2.00 fixes CplusTESample so that it works with MPW 3.2.
  122. Minor modifications were made to the makefile and Document.h